<template>
  <div class="picking zy-content">
<!--    <div class="searchBox search-box-layout">-->
<!--      <Row :gutter="24">-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('配置类型') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Select v-model="searchParams.category" filterable clearable-->
<!--                      :placeholder="`${$t('common.selectInfo')}`">-->
<!--                <Option v-for="(item) of category"-->
<!--                        :value="item.value"-->
<!--                        :key="item.value"-->
<!--                        :label="item.label">-->
<!--                </Option>-->
<!--              </Select>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('名称') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Input type="text" v-model="searchParams.name"-->
<!--                     :placeholder="`${$t('common.inputInfo')}`" class="inputBorder"-->
<!--                     :maxlength="32"/>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('计划') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Select v-model="searchParams.planIds"-->
<!--                      filterable-->
<!--                      multiple-->
<!--                      clearable-->
<!--                      :max-tag-count="1"-->
<!--                      :placeholder="`${$t('common.selectInfo')}`">-->
<!--                <Option v-for="(item) of planList"-->
<!--                        :value="item.id"-->
<!--                        :key="item.id"-->
<!--                        :label="item.planName">-->
<!--                </Option>-->
<!--              </Select>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('小时') }}</p>-->
<!--            <div class="ipt">-->
<!--              <InputNumber class="inputNumberWrapper" :min="1"-->
<!--                           :max="9999999999999999999"-->
<!--                           v-model="searchParams.itemHours" clearable/>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('角色') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Select v-model="searchParams.role"-->
<!--                      clearable-->
<!--                      @on-change="roleChange"-->
<!--                      :placeholder="`${$t('common.selectInfo')}`">-->
<!--                <Option v-for="item of roleArr"-->
<!--                        :value="item.id"-->
<!--                        :key="item.id"-->
<!--                        :label="item.name">-->
<!--                </Option>-->
<!--              </Select>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('用户') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Select v-model="searchParams.user"-->
<!--                      clearable-->
<!--                      filterable-->
<!--                      :placeholder="`${$t('common.selectInfo')}`">-->
<!--                <Option v-for="item of userArr"-->
<!--                        :value="item.id"-->
<!--                        :key="item.id"-->
<!--                        :label="item.realname">-->
<!--                </Option>-->
<!--              </Select>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('类型') }}</p>-->
<!--            <div class="ipt">-->
<!--              <RadioGroup v-model="searchParams.pushType">-->
<!--                <Radio :label="0">Mail</Radio>-->
<!--                <Radio :label="1">Watch</Radio>-->
<!--                <Radio :label="4">Message</Radio>-->
<!--              </RadioGroup>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="6">-->
<!--          <div>-->
<!--            <p class="label">{{ $t('描述') }}</p>-->
<!--            <div class="ipt">-->
<!--              <Input type="text" v-model="searchParams.description"-->
<!--                     :placeholder="`${$t('common.inputInfo')}`" class="inputBorder"-->
<!--                     :maxlength="32"></Input>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--        <Col span="4">-->
<!--          <div>-->
<!--            <p class="label hide-label">&#45;&#45;</p>-->
<!--            <div class="ipt">-->
<!--              <Button class="search-btn" type="primary" @click="changeNum"-->
<!--                      v-if="checkBtnPermission.dcmMaintainItemList">{{ $t('common.Query') }}-->
<!--              </Button>-->
<!--              <Button-->
<!--                  class="reset-btn"-->
<!--                  @click="changeNum()"-->
<!--              >{{ $t('common.reset') }}-->
<!--              </Button>-->
<!--            </div>-->
<!--          </div>-->
<!--        </Col>-->
<!--      </Row>-->
<!--    </div>-->
    <div class="list-layout mt16">
      <div class="btns clear">
        <span class="title">{{ $t('common.listInformation') }}</span>
        <Button @click="createfaultCodeShowH" v-has="'configAdd'">{{
            $t('maintenance.New')
          }}
        </Button>
<!--        <Button @click="handleDelete" v-if="checkBtnPermission.dcmMaintainItemAdd">{{-->
<!--            $t('maintenance.Delete')-->
<!--          }}-->
<!--        </Button>-->
<!--        <Button @click="handleOutRecords">{{ $t('maintenance.Export') }}</Button>-->
<!--        <Button @click="batchImport">{{ $t('maintenance.Import') }}</Button>-->
<!--        <Button @click="exportTemplate">{{ $t('maintenance.Download') }}</Button>-->
        <Button @click="getTableColumns(columns)">{{ handleContextMenuStatus ? $t('显示操作栏'):$t('隐藏操作栏') }}</Button>
      </div>
      <div class="tableContent">
        <Table border  class="resizable-table" @on-column-width-resize="onColumnWidthResize" ellipsis ref="selection" :columns="columnsList" :data="data"
               @on-selection-change="onSelectChange">
          <template slot-scope="{ row }" slot="action">
            <span class="operationBtn" @click="edit(row)" v-has="'configEdit'"><i
                class="iconfont zy-common-bianji"></i>{{ $t('maintenance.Edit') }}</span>
            <span class="operationBtn" @click="deleteRow(row)"
                  v-has="'configDelete'"><i
                class="iconfont zy-common-shanchu"></i>{{ $t('maintenance.DeleteObj') }}</span>
          </template>
          <template slot-scope="{ row }" slot="disabledinfo">
            <span>{{disabledList[row.disabled]}}</span>
          </template>
        </Table>
      </div>
      <div class="pageWrap mt16">
<!--        <pageLeftTitle :total="total" :selected="delIds.length"/>-->
        <Page
            :total="total"
            :page-size="pageSize"
            :page-size-opts="$variable.pageSizes"
            :current="pageNum"
            @on-change="changePageNum"
            @on-page-size-change="changePageSize"
            show-sizer
            show-total
        />
      </div>
    </div>


    <Modal :mask-closable="false" v-model="createStatus"
           :title="addtitle"
           class="modal-content-item-layout"
           @on-cancel="cancleOk"
           width="90%">
      <div class="addProject">
        <Form ref="form" class="formList"
              :model="formItem"
              label-position="top"
              :rules="ruleValidate">
          <div class="content-item">
            <span class="content-item-title">{{ $t('推送规则') }}</span>
            <div class="pd16">
              <Row :gutter="20">
                <Col span="8">
                  <FormItem :label="$t('配置类型')" prop="category">
                    <Select v-model="formItem.category"
                            filterable
                            clearable
                            :placeholder="`${$t('common.selectInfo')}`">
                      <Option v-for="(item) of category"
                              :value="item.value"
                              :key="item.value"
                              :label="item.label">
                      </Option>
                    </Select>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('配置方案名称')" prop="name">
                    <Input type="text"
                           v-model="formItem.name"
                           :placeholder="`${$t('common.inputInfo')}`"/>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('维保计划')" prop="planIds">
                    <Select v-model="formItem.planIds"
                            filterable
                            multiple
                            clearable
                            :max-tag-count="1"
                            :placeholder="`${$t('common.selectInfo')}`">
                      <Option v-for="(item) of planList"
                              :value="item.id"
                              :key="item.id"
                              :label="item.planName">
                      </Option>
                    </Select>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('提前通知时间(s)')" prop="notificationTime">
                    <Input  icon="ios-clock-outline"
                            @on-keyup="levelCheck"
                            v-model="formItem.notificationTime"/>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('角色')">
                    <Select v-model="formItem.role"
                            clearable
                            @on-change="roleChange"
                            :placeholder="`${$t('common.selectInfo')}`">
                      <Option v-for="item of roleArr"
                              :value="item.id"
                              :key="item.id"
                              :label="item.name">
                      </Option>
                    </Select>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('用户')" prop="userIds">
                    <Select v-model="formItem.userIds"
                            clearable
                            multiple
                            :max-tag-count="1"
                            filterable
                            :remote-method="searchUserlist"
                            :placeholder="`${$t('common.selectInfo')}`">
                      <Option v-for="item of userArr"
                              :value="item.id"
                              :key="item.id"
                              :label="item.empno + '-' + item.realname">
                      </Option>
                    </Select>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('描述')">
                    <Input type="text"
                           v-model="formItem.description"
                           :placeholder="`${$t('common.inputInfo')}`"/>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('通知类型')" prop="pushType">
                    <CheckboxGroup v-model="formItem.pushType">
                      <!-- <Checkbox label="1">E-Mail</Checkbox>
                      <Checkbox label="2">Watch</Checkbox> -->
                      <Checkbox label="1">{{$t('电子邮件')}}</Checkbox>
                      <Checkbox label="2">{{$t('智能手表')}}</Checkbox>
                      <!-- <Checkbox label="3">Message</Checkbox> -->
                    </CheckboxGroup>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem :label="$t('是否禁用')" prop="disabled">
                    <RadioGroup  v-model="formItem.disabled">
                      <Radio :label="1" :disabled="!formItem.id">{{$t('是')}}</Radio>
                      <Radio :label="0" :disabled="!formItem.id">{{$t('否')}}</Radio>
                    </RadioGroup>
                  </FormItem>
                </Col>
              </Row>
            </div>
          </div>
        </Form>
      </div>

      <div slot="footer">
        <Button type="default" @click="cancleOk" >{{$t('common.Cancle')}}</Button>
        <Button type="primary" @click="addOk('form')" >{{$t('maintenance.Confirmed')}}</Button>
      </div>
    </Modal>

    <Modal :mask-closable="false" v-model="delFaultCodeShowF" :title="`${$t('maintenance.Deleteremind')}`">
      <Row class="enableContent">
        <Col span="24" class="enableContentInner">
          <img width="95px" src="~images/event/del.png" alt="" />
        </Col>
        <Col span="24" class="enableTips">
          <span
          >是否确认删除？</span
          >
        </Col>
      </Row>
      <div slot="footer">
        <Button type="default" @click="delFaultCodeShowF = false">{{$t('common.Cancle')}}</Button>
        <Button type="primary" @click="deleteOk">{{$t('maintenance.Confirmed')}}</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
import fileDownload from "js-file-download";
import toggleTableOperation from "@/mixins/toggleTableOperation";
export default {
  name: "rule",
  mixins:[toggleTableOperation],
  data() {
    return {
      createStatus:false,
      addtitle:'',
      disabledList:['否','是'],
      roleArr:[],
      userArr:[],
      planList:[],
      ruleValidate: {
        category: [
          { required: true, message: this.$t('common.selectInfo')}
        ],
        name: [
          { required: true, message: this.$t('common.inputInfo')}
        ],
        planIds: [
          { required: true, message: this.$t('common.selectInfo')}
        ],
        notificationTime: [
          { required: true, message: this.$t('common.inputInfo')}
        ],
        userIds: [
          { required: true, message: this.$t('common.selectInfo')}
        ],
        pushType: [
          { required: true, message: this.$t('common.selectInfo')}
        ],
        disabled: [
          { required: true, message: this.$t('common.selectInfo')}
        ]
      },
      importExcelState: false,
      deviceNameList: [],
      status: 0,
      confirmId: '',
      delId: '',
      searchParams: {
        pushType:['1']
      },
      checkBtnPermission: {},
      total: 0,
      pageSize: 10,
      pageNum: 1,
      pageSizeOption: [10, 20, 30],
      importVisible: false,
      allCheck: false,
      create: false,
      confirmBatchFaultCodeShowF: false,
      confirmBatchLoading: false,
      confirmFaultCodeShowF: false,
      confirmLoading: false,
      delFaultCodeShowF: false, //是否显示删除弹窗
      delLoading: false,
      delBatchFaultCodeShowF: false,
      delBatchLoading: false,
      formItem: {

      },
      delIds: [],
      category: [
        {label: '维保', value: 1}
      ],
      columns: [
        // {
        //   type: 'selection',
        //   align: 'center',
        //   width: 60
        // },
        {
          title: `${this.$t('配置类型')}`,
          key: "categoryStr",
          minWidth: 160,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('配置方案名称')}`,
          key: "name",
          minWidth: 180,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('维保计划')}`,
          key: "planNames",
          minWidth: 150,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('提前通知时间')}`,
          key: "notificationTime",
          minWidth: 160,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('接收用户')}`,
          key: "userNames",
          minWidth: 160,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('通知类型')}`,
          key: "pushTypeStr",
          width: 200,
          align: "center",
          tooltip: true,
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('创建人')}`,
          key: "createByStr",
          align: "center",
          width: 150,
          tooltip: true,
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('创建时间')}`,
          key: "createTime",
          width: 200,
          align: "center",
          tooltip: true,
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('是否禁用')}`,
          key: "disabled",
          slot: "disabledinfo",
          width: 110,
          align: "center",
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('备注')}`,
          key: "description",
          width: 200,
          align: "center",
          tooltip: true,
          resizable: true,tooltip: true,
        },
        {
          title: `${this.$t('common.operation')}`,
          slot: "action",
          fixed: 'right',
          minWidth: 240,
          align: "center"
        },
      ],
      deviceTypeList: [],
      data: [],
    };
  },
  created() {
    this.getTableColumnsWidth(this.columns)
    this.searchList()
    this.getFaultCategory("设备类型")
    this.searchRole()
    this.searchPlan()
    this.searchUserlist()
  },
  mounted() {
    let itemList = JSON.parse(window.localStorage.getItem('USER_URI'))
    for (let item of itemList) {
      if (item.code == "dcmMaintainItemAdd") {
        this.checkBtnPermission.dcmMaintainItemAdd = true
      }
      if (item.code == "dcmMaintainItemEdit") {
        this.checkBtnPermission.dcmMaintainItemEdit = true
      }
      if (item.code == "dcmMaintainItemDelete") {
        this.checkBtnPermission.dcmMaintainItemDelete = true
      }
      if (item.code == "dcmMaintainItemList") {
        this.checkBtnPermission.dcmMaintainItemList = true
      }
      if (item.code == "dcmMaintainItemVerifyById") {
        this.checkBtnPermission.dcmMaintainItemVerifyById = true
      }
      if (item.code == "dcmMaintainItemBatchVerify") {
        this.checkBtnPermission.dcmMaintainItemBatchVerify = true
      }
      if (item.code == "dcmMaintainItemBatchDelete") {
        this.checkBtnPermission.dcmMaintainItemBatchDelete = true
      }
    }
  },
  methods: {
    levelCheck(e){
      e.target.value = e.target.value.replace(/(^\s*)|(\s*$)/g, "");
      const reg = /[^\d.]/g;
      e.target.value = e.target.value.replace(reg, "");
      e.target.value = e.target.value.replace(/^\./g, "");
      e.target.value = e.target.value
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".");
      e.target.value = e.target.value.replace(
          /^(\-)*(\d+)\.(\d\d).*$/,
          "$1$2.$3"
      );
    },
    edit(row) {
      this.addtitle = `${this.$t('编辑')}`
      this.createStatus = true
      this.formItem ={
        id:row.id,
        category:row.category,
        name:row.name,
        disabled:row.disabled,
        pushType:row.pushType.split(','),
        description:row.description,
        notificationTime:row.notificationTime.replace('s',''),
        planIds:row.planIds.split(','),
        userIds:row.userIds.split(','),
      }
      this.formItem.planIds =  this.formItem.planIds.map(val=>Number(val))
      this.formItem.userIds =  this.formItem.userIds.map(val=>Number(val))
    },
    cancleOk(){
      this.createStatus = false
      this.formItem = {}
      this.$refs.form.resetFields()
    },
    addOk(name) {
      this.$refs[name].validate((valid) => {
        if (!valid) {
          return
        } else {
          if (this.formItem.id) {
            this.axios({
              method:'post',
              url: "/dms/message/config/edit",
              data:{
                ...this.formItem,
                pushType:this.formItem.pushType.join(','),
                planIds:this.formItem.planIds.join(','),
                userIds:this.formItem.userIds.join(','),
              }
            }).then(res => {
              if (res.code === 200) {
                this.changeNum();
                this.$Message.success(res.msg);
                this.cancleOk()
              } else {
                this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
              }
            })
          } else {
            this.axios({
              method:'post',
              url: "/dms/message/config/add",
              data:{
                ...this.formItem,
                pushType:this.formItem.pushType.join(','),
                planIds:this.formItem.planIds.join(','),
                userIds:this.formItem.userIds.join(','),
              }
            }).then(res => {
              if (res.code === 200) {
                this.changeNum();
                this.$Message.success(res.msg);
                this.cancleOk()
              } else {
                this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
              }
            })
          }
        }
      })
    },
    roleChange(id){
      if (this.formItem.userIds && this.formItem.userIds.length){
          this.formItem.userIds = []
      }
      let params = {
        pageNum: 1,
        pageSize: 100,
        id
      }
      this.axios({
        method:'get',
        url: "/basic/role/getUsersByRoleId",
        params
      }).then(res=>{
        if(res.code===200){
          res.data.list.forEach(val=>val.id = val.userId)
          this.userArr = res.data.list
        }else{
          this.$Message.warning(({content:res.msg,duration:6,closable:true}));
        }
      });
    },
    searchUserlist(key) {
      let params = {
        key
      }
      this.axios({
        method: 'get',
        url: '/basic/user/searchUser',
        params
      }).then(res => {
        if (res.code === 200) {
          this.userArr = res.data
        }else {
          this.$Message.warning(({content:res.msg,duration:6,closable:true}))
        }
      })
    },
    //用户
    // searchUserlist() {
    //   let params = {
    //     pageNum: 1,
    //     pageSize: 100,
    //     certificate: -1
    //   };
    //   this.axios({
    //     method: 'get',
    //     url: '/basic/user/findUserList',
    //     params
    //   }).then(res => {
    //     if (res.code === 200) {
    //       this.userArr = res.data.list
    //     } else {
    //       this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
    //     }
    //   })
    // },
    //角色
    searchRole() {
      let params = {
        pageNum: 1,
        pageSize: 100,
      };
      this.axios({
        method: 'get',
        url: '/basic/role/page',
        params
      }).then(res => {
        if (res.code === 200) {
          this.roleArr = res.data.list
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      })
    },
    //有效计划
    searchPlan() {
      let data = {
        status: 0,
        pageNo: 1,
        pageSize: 100,
      };
      this.axios({
        method: 'POST',
        url: '/dms/dcmMaintainPlan/list',
        data
      }).then(res => {
        if (res.code === 200) {
          this.planList = res.data.list
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      })
    },
    //获取故障数据
    getFaultCategory(name) {
      this.axios({
        method: 'get',
        url: '/dms/faultCategory/basicDict',
        params: {name}
      }).then(res => {
        if (res.code === 200) {

          if (name === '故障分类') {
            this.faultCategoryList = res.data.map(item => {
              if (item.value) return item;
            })
          } else if (name === '设备类型') {
            this.deviceTypeList = res.data.map(item => {
              if (item.value) return item;
            })
          }
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}))
        }
      })
    },
    deviceNameChange(val) {
      if (val) {
        this.searchParams.deviceType = val
      }
    },
    handleOutRecords() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        ids: this.delIds,
        ...this.searchParams
      }
      const filName = '保养项目'
      this.axios({
        method: 'post',
        url: '/dms/dcmMaintainItem/exportItem',
        responseType: 'blob',
        data: params
      }).then(res => {
        fileDownload(res, filName + '.xlsx')
      })
    },
    importExcelChange(val) {
      this.importExcelState = false;
      if (val === 'success') {
        this.changeNum();
        this.$Message.success('导入成功!')
      }
    },
    //下载模板
    exportTemplate() {
      const filName = "保养项目下载模板";
      this.axios({
        method: "get",
        url: "/dms/dcmMaintainItem/downloadTemplate",
        responseType: "blob",
      }).then((res) => {
        fileDownload(res, filName + ".xlsx");
      });
    },
    getDeviceNameList(deviceName) {
      if (deviceName) {
        this.axios({
          method: 'get',
          url: '/dms/dcmMaintainItem/selectDeviceNames',
          params: {
            deviceName
          }
        }).then(res => {
          if (res.code == 200) {
            this.deviceNameList = res.data.map(val => ({
              label: val,
              value: val
            }))
          }
        })
      }
    },
    // getDeviceList() {
    //   this.axios({
    //     method: 'get',
    //     url: '/dms/dmsCategory/getSelectList',
    //     params: {}
    //   }).then(res => {
    //     if(res.code === 200){
    //       this.category = res.data
    //     }else{
    //       this.$Message.warning(({content:res.msg,duration:6,closable:true}));
    //     }
    //   })
    // },
    tabsClick(name) {
      this.status = name
      this.delIds = ''
      this.pageNum = 1
      this.searchList()
      // if (name === 0) {
      //     this.$refs.productConfigComponent.searchBtn();
      // } else  if (name === 1){
      //     console.log(this.$$refs);
      //     this.$refs.boxConfigComponent.searchBtn();
      // }else{
      //     this.$refs.shfitconfigComponent.searchBtn();
      // }
    },
    createfaultCodeShowH() {
      this.formItem.disabled = 0
      this.addtitle = `${this.$t('新增')}`
      this.createStatus = true
    },
    //确认
    confirm(row) {
      this.confirmId = row.id
      this.confirmFaultCodeShowF = true
    },
    deleteConfirmOk() {
      this.confirmLoading = true
      this.axios({
        method: 'post',
        url: '/dms/dcmMaintainItem/verifyById',
        data: {
          id: this.confirmId
        }
      }).then(res => {
        
        if (res.code === 200) {
          this.searchList()
          this.$Message.success(({content: '确认成功！', duration: 2, closable: true}));
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      }).finally(() => {
        this.confirmLoading = false
        this.confirmFaultCodeShowF = false
      })
    },
    //批量确认
    handleBatchConfirm() {
      this.confirmBatchFaultCodeShowF = true
    },
    deleteBatchConfirmOk() {
      this.confirmBatchLoading = true
      this.axios({
        method: 'post',
        url: '/dms/dcmMaintainItem/batchVerify',
        data: {
          ids: this.delIds
        }
      }).then(res => {
        
        if (res.code === 200) {
          this.searchList()
          this.$Message.success(({content: '批量确认成功！', duration: 2, closable: true}));
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      }).finally(() => {
        this.confirmBatchLoading = false
        this.confirmBatchFaultCodeShowF = false
      })
    },
    handleDelete() {
      if (!(this.delIds && this.delIds.length)) {
        this.$Message.warning(({content: `${this.$t('common.deleteItems')}`, duration: 2, closable: true}));
        return
      }
      this.delFaultCodeShowF = true
    },
    //删除
    deleteRow(row) {
      this.delId = row.id
      this.delFaultCodeShowF = true
    },
    deleteOk() {
      const obj = {
        method: 'get',
        url: '/dms/message/config/del',
        params: {}
      }
      // if (this.delIds && this.delIds.length) {
      //   obj.url = '/dms/dcmMaintainItem/batchDelete'
      //   obj.params.ids = this.delIds.join(',')
      // }
      if (this.delId) {
        obj.params.id = this.delId
      }
      this.axios(obj).then(res => {
        if (res.code === 200) {
          this.changeNum()
          this.$Message.success(({content: '删除成功！', duration: 2, closable: true}));
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      }).finally(() => {
        this.delFaultCodeShowF = false
      })
    },
    //批量删除
    handleBatchDelete() {
      if (!(this.delIds && this.delIds.length)) {
        this.$Message.error(`${this.$t('common.deleteItems')}`);
        return
      }
      this.delBatchFaultCodeShowF = true
    },
    deleteBatchOk() {
      this.delBatchLoading = true
      this.axios({
        method: 'delete',
        url: '/dms/dcmMaintainItem/batchDelete',
        params: {
          ids: this.delIds.toString()
        }
      }).then(res => {
        
        if (res.code === 200) {
          this.searchList()
          this.$Message.success(({content: '批量删除成功！', duration: 2, closable: true}));
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      }).finally(() => {
        this.delBatchLoading = false
        this.delBatchFaultCodeShowF = false
      })
    },
    onSelectChange(selection) {
      let myArray = [];
      selection.map((item) => {
        myArray.push(item.id);
      });

      this.delIds = myArray;
      if (selection.length > 1) {
        this.allCheck = true;
      } else {
        this.allCheck = false;
      }
    },
    handleSearch() {
      // this.status = status
      this.searchList()
    },
    //分页
    changeNum() {
      this.pageNum = 1;
      this.searchList();
    },
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.searchList();
    },
    changePageNum(val) {
      this.pageNum = val;
      this.searchList();
    },
    searchList() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        // ...this.searchParams
      }
      this.axios({
        method: 'get',
        url: '/dms/message/config/list',
        params
      }).then(res => {
        if (res.code === 200) {
          res.data.list.forEach(val=>val.notificationTime = val.notificationTime + 's')
          this.data = res.data.list
          this.total = res.data.total
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      })
    },
    batchImport() {
      this.importExcelState = true;
    },
    exportProject() {
    },
    importOk() {
    },
    importCancel() {
    },
  },
};
</script>

<style lang="scss" scoped>
.ivu-input-number {
  width: -webkit-fill-available;
}
.project {
  //background: #ffffff;
  height: calc(100vh - 150px);

  .title {
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    padding: 10px;
    border-bottom: 1px solid #dddddd;

    .icon {
      display: flex;

      .creatBtnright {
        display: flex;
        align-items: center;
        font-size: 16px;

        i {
          font-size: 36px;
        }
      }
    }
  }

  .tab {
    height: calc(100% - 100px);

    .ivu-tabs-bar {
      padding-left: 30px;
    }

    .ivu-tabs-tab {
      font-size: 18px;
    }
  }
}

.addModal {
}

.batchImport {
  .import {
    display: flex;
    align-items: center;

    .selectFile {
      margin-right: 10px;
    }

    .selectFile::before {
      content: "*";
      color: red;
      padding-right: 5px;
    }
  }

  .download {
    .clickthis {
      color: #187bdb;
      text-decoration: underline;
      cursor: pointer;
    }
  }
}
</style>
